
package TransportesMarroquin;

import java.awt.Toolkit;
import javax.swing.text.*;



public class Limitador extends DefaultStyledDocument {
    private final int caracteresMaximos;

    public Limitador( int caracteresMaximos ) {
this.caracteresMaximos = caracteresMaximos;
}

public void insertString(int offs, String str, AttributeSet a)
    throws BadLocationException {
        if (str.indexOf("?") == -1 && str.indexOf("?") == -1 && (getLength() + str.length()) <= caracteresMaximos)
            super.insertString(offs, str, a);
        else
            Toolkit.getDefaultToolkit().beep();
}


}
